<% content_for :head do %>
  <%= tag.meta property: "og:type", content: "profile" %>
  <%= tag.meta name: "description", content: truncate(sanitize(@creator.caption), length: 80) if @creator.caption.present? %>
  <%= tag.link rel: "alternate", type: Mime[:oembed], href: creator_url(@creator, format: :oembed), title: @creator.name %>
<% end %>

<%= content_for :items do %>
  <%= turbo_stream_from @creator %>
  <div class="card mb-3 <%= "remote-actor" if @creator.remote? %>">
    <div class="card-header"><%= @creator.model_name.human %></div>
    <%= content_tag :div, class: "card-body row me-0 ms-0 with-background", style: (@creator.banner ? "background-image: url(#{banner_creator_path(@creator)}); background-position: center; background-size: cover" : nil) do %>
      <% if @creator.avatar %>
        <div class="col col-auto">
          <%= Avatar(url: avatar_creator_path(@creator), size: :large) if @creator.avatar %>
        </div>
      <% end %>
      <div class="col col-auto">
        <%= content_tag(:div, class: "text-center") do %>
          <h2>
            <%= @creator.name %>
          </h2>
          <% if SiteSettings.federation_enabled? %>
            <p>
              <% if @creator.remote? %>
                <small class="text-secondary"><%= link_to @creator.federails_actor.at_address, @creator.federails_actor.profile_url, target: "new" %></small>
              <% elsif SiteSettings.federation_enabled? %>
                <small class="text-secondary">
                  <%= CopyableText(text: @creator.federails_actor.at_address, label: t("general.copy_fediverse_handle")) %>
                </small>
              <% end %>
            </p>
          <% end %>
          <%= FollowButton(follower: current_user, target: @creator) %>
        <% end %>
      </div>
      <div class="col">
        <%= content_tag(:p, class: "lead") { @creator.caption } if @creator.caption %>
        <% model_count = policy_scope(Model).where(creator: @creator).count %>
        <p><%= "#{model_count} #{Model.model_name.human count: model_count}" %></p>
        <%= content_tag(:p) { t("general.followers", count: @creator.followers.count) } if SiteSettings.social_enabled? %>
        <p><%= AccessIndicator(object: @creator, text: true) %></p>
      </div>
      <div class="col col-auto">
        <%= LinkList links: @creator.links %>
      </div>
    <% end %>
    <% if @creator.notes %>
      <hr class="mt-0">
      <%= content_tag :div, class: "card-body row me-0 ms-0" do %>
        <%= markdownify @creator.notes %>
      <% end %>
    <% end %>
  </div>
<% end %>

<% content_for :actions do %>
  <%= link_to safe_join([Icon(icon: "pencil", label: t(".edit")), t(".edit")], " "), edit_creator_path(@creator), class: "btn btn-primary" if policy(@creator).edit? %>
  <%= ReportButton(object: @creator, path: new_creator_report_path(@creator)) %>
<% end %>

<%= render "models/list" %>
